package j.framework.qmd.core;

import j.framework.core.LoginUser;
import j.util.jdbc.QueryJdbcTemplate;

import java.util.List;
import java.util.Map;

/**
 * User: jason
 * Date: 14-7-18 上午10:43
 */
public interface QueryDataHandler {

    Object getColumnValue(QueryFieldMetadata fieldMetadata, Object value, Map<String, Object> rowData);

    String buildWhereClause(LoginUser user, Map<String, String> queryParams, List<Object> args);

    void prepareCall(LoginUser user, Map<String, String> queryParams, Map<String, Object> callParams);

    /**
     * 获取操作
     * @param rowData
     * @return
     */
    String getOperatorHtml(LoginUser user, Map<String, Object> rowData);

    /**
     * 执行查询前将会被调用，若返回true，仍执行框架查询
     * @param qmd
     * @param queryParams
     * @param queryResult 执行的结果
     * @return
     */
    boolean beforeQuery(QueryJdbcTemplate qjt, QueryMetadata qmd, Map<String, String> queryParams, QueryResult queryResult);

    /**
     * 事后查询
     * @param qmd
     * @param queryResult
     */
    void doAfterQuery(QueryJdbcTemplate qjt, QueryMetadata qmd, Map<String, String> queryParams, QueryResult queryResult);
}
